package com.joinway.admin.hsqldb;

import static java.lang.System.out;

import java.sql.Connection;
import java.sql.DriverManager;

import org.hsqldb.Server;
import org.hsqldb.persist.HsqlProperties;

public class HSqldbClient {

	public static void main(String[] args) throws Exception {
//		test1();
		test2();
	}

	public static void test1() throws Exception {
		Class.forName("org.hsqldb.jdbcDriver");
		Connection c = DriverManager.getConnection("jdbc:hsqldb:mem:platform", "SA", "");
//		Statement stmt = c.createStatement();
//		ResultSet rs = stmt.executeQuery("select 1 from dual");
//		if(rs.next()){
//			out.println(rs.getString(1));
//		}
//		stmt.execute("select 1 from dual");
		out.println(c.getAutoCommit());
	}
	
	public static void test2() throws Exception {
		Server server = new Server();
		
		HsqlProperties props = new HsqlProperties();
		props.setProperty("database.0", "mem:platform");
		props.setProperty("dbname.0", "platform");
		props.setProperty("remote_open", true);
		props.setProperty("reconfig_logging", false);
		
		server.setProperties(props);
		server.start();
		
	}
}
